let http = require('http');
let url = require('url');
let users = require('./users.json');

const server = http.createServer((req,res)=>{
    res.setHeader("Content-type","text/html;charset=utf-8");
    let{username="",pwd=""}=url.parse(req.url,true).query;
    console.log(username,pwd);
    var loginRes = users.find(item=>(item.username==username && item.pwd == pwd));
    if(loginRes){
    res.write('用户名密码正确');
    }else{
    res.write('用户名或密码错误');
    }
    res.end();
})

server.listen(3001);